package com.gaotai.wangfei.exam.system.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 
 * <p>
 * Description: [servlet测试类]
 * </p>
 * 
 * @author <a href="mailto: wangfei@gaotai.cn">王飞</a>
 * @version $Revision$
 */
public class TestServlet extends HttpServlet
{
	/**
	 * <p>
	 * [字段功能描述]
	 * </p>
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 
	 * <p>
	 * 因处理逻辑一致，所以将get请求全部转到post请求处理
	 * </p>
	 * 
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 * @author:wangfei 2016-3-17
	 * @update: [updatedate] [changer][change description]
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{

		doPost(request, response);
	}

	/**
	 * 
	 * <p>
	 * 部分逻辑处理--用来测试自定义标签
	 * </p>
	 * 
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 * @author:wangfei 2016-3-17
	 * @update: [updatedate] [changer][change description]
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/views/test.jsp");
		List<String> stringList = new ArrayList<String>();
		stringList.add("王飞");
		stringList.add("陆晓祥");
		stringList.add("齐军");
		stringList.add("陈怀东");
		request.setAttribute("stringList", stringList);//存值
		rd.forward(request, response);
	}

}
